<?php
$mySession = Session::getInstance();
if($mySession->getConnect()) {


			# Inclusion des  classes de gestion
			include_once "class/app/objectList.class.php";
			include_once "class/app/categorieList.class.php";
			include_once "class/app/personList.class.php";
			include_once "class/app/cityList.class.php";
			include_once "class/app/exchange.class.php";
			
			if (  (isset($_GET['id']) && !empty($_GET['id']))   &&   (isset($_GET['idOther']) && !empty($_GET['idOther']))  ) {
				
				/* UTILISATEUR CONNECTER */
				$LesObjects = new ObjectList();
				$unObjet = $LesObjects->getObject($_GET['id']);
				
				$idPerson1 = $unObjet->getIdPerson();
				$idObjectPerson1 = $unObjet->getIdObject();
				
				
				/* OBJET DE L'AUTRE UTILISATEUR */
				$unObjet = $LesObjects->getObject($_GET['idOther']);
				
				$idPerson2 = $unObjet->getIdPerson();
				$idObjectPerson2 = $unObjet->getIdObject();				
				date_default_timezone_set('Europe/Paris');
				
				
				
				$exchange = new Exchange();
				$exchange->initialisation('', $idPerson1, $idPerson2, date('Y-m-d'), $idObjectPerson1, $idObjectPerson2, 'En attente de l\'autre utilisateur', 'En attente de votre r&eacute;ponse');
				
				
				if($exchange->add()) {
					$laPersonne = $mySession->getPersonne();
					$laPersonne->chargerMesEchanges();
					print ("<script language = \"JavaScript\">");
					print ("location.href = './';");
					print ("</script>");	
				} else {
					echo "Une erreur est survenu";
				}
				
				
				
				
		}




} else {
	print ("<script language = \"JavaScript\">");
	print ("location.href = './';");
	print ("</script>");
}
?>